package com.zzc.emotisenseclassroom.dbservice.user.impl;

import com.zzc.baseRepository.componet.CommonSqlBuider;
import com.zzc.baseRepository.componet.WhereConditionEnum;
import com.zzc.baseRepository.componet.Wheres;
import com.zzc.baseRepository.componet.interfaces.BaseDbService;
import com.zzc.emotisenseclassroom.dao.user.SchoolDao;
import com.zzc.emotisenseclassroom.dbservice.user.SchoolDbService;
import com.zzc.emotisenseclassroom.dto.user.SchoolDTO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Copyright Zzc
 * FileName: SchoolDbServiceImpl
 * Author:   Zzc
 * Date:     2024/4/2420:55
 * Description:学校信息表 db service 实现类
 * hISTORY:
 * <author>  <time>     <version>    <desc>
 * 作者姓名   修改时间       版本号       描述
 * Zzc                   1.0.0
 */
@Service
public class SchoolDbServiceImpl extends BaseDbService<SchoolDao> implements SchoolDbService {

    @Override
    public List<SchoolDTO> getSchoolInfoList(String schoolName) {
        CommonSqlBuider buider = new CommonSqlBuider();
        buider.selectFrom(SchoolDao.class);
        buider.select(SchoolDao.SCHOOL_ID);
        buider.select(SchoolDao.SCHOOL_NAME);

        if (StringUtils.isNotBlank(schoolName)){
            Wheres where = buider.where();
            where.andWhenLike(SchoolDao.SCHOOL_NAME, WhereConditionEnum.LIKE, schoolName);
        }

        return baseDao.list(buider, SchoolDTO.class);
    }
}
